import json
import lib.mongodb
import pymongo
table = 'main_kongqi'
title = '123'
sheets = '兰大榆中校区'
# myclient = pymongo.MongoClient("mongodb://localhost:27017/")
# mydb = myclient[table]
# mycol = mydb[title]
# x = mycol.find_one()
# datalist = []
# sheetList = []
# avgs = x['avg']
# monthList = []
# for types in avgs[sheets]:
#     for i in avgs[sheets][types]:
#         month = int(i.split('-')[1])
#         data = lib.mongodb.getSearch(title,sheets,month)
#         if month not in monthList:
#             monthList.append(month)
#             datalist.append(data['data'])
# returndata = []
month = '2015-01-01_2015-01-02'
# month = month.split('_')
# start_time = month[0]
# start_time = start_time.replace('-','')
# end_time = month[1]
# end_time = end_time.replace('-','')
# for data in datalist:
#     for j in data:
#         # print(j)
#         date = j.replace('-','')
#         if int(date)>=int(start_time) and int(date) <= int(end_time):
#             data2 = {'title':data[j]['title'],'date':j,'daySO2':data[j]['daySO2'],'dayPM25':data[j]['dayPM25'],'dayNO':data[j]['dayNO'],'dayNO2':data[j]['dayNO2'],'dayNOx':data[j]['dayNOx'],'dayO3':data[j]['dayO3'],'dayCO':data[j]['dayCO'],'dayPM10':data[j]['dayPM10']}
#             returndata.append(data2)
# print(returndata)
month = month.split('_')
start_time = month[0]
end_time = month[1]
print(start_time)
print(end_time)
start_time = start_time.split('-')
end_time = end_time.split('-')
print(start_time)
print(end_time)